import httpInstance from "@/utils/http";

// 获取分类
export async function getCategories() {
  try {
    const res = await httpInstance.get('/api/category/list');
    return res.data;
  } catch (error) {
    console.error('Error fetching categories:', error);
    throw error;
  }
};

// 获取轮播图
export async function getCarousel() {
  try {
    const res = await httpInstance.get('/api/book/carousel');
    return res.data;
  } catch (error) {
    console.error('Error fetching carousel:', error);
}
}

// 获取书籍列表
export async function getBooksList() {
  try {
    const res = await httpInstance.get('/api/book/list');
    return res.data;
  }
  catch (error) {
    console.error('Error fetching books list:', error);
    throw error;
  }
}

// 获取书籍详情
export async function getBook(bookId) {
  try {
    const res = await httpInstance.get(`/api/book/${bookId}`);
    return res.data;
  } catch (error) {
    console.error('Error fetching book:', error);
    throw error;
  }
}
